package com.ruoyi.web.controller.home;

import com.ruoyi.business.service.IAppCustomerService;
import com.ruoyi.business.service.IAppTaskOrderService;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.SysLogininfor;
import com.ruoyi.system.service.ISysLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class HomeController {

    @Autowired
    private ISysLogininforService logininforService;
    @Autowired
    private IAppCustomerService appCustomerService;
    @Autowired
    private IAppTaskOrderService appTaskOrderService;

    @RequestMapping("/welcome")
    public AjaxResult getWelcome(){
        List<Integer> weekLogCountList = logininforService.getWeekLoginCount();
        AjaxResult ajaxResult = new AjaxResult(200, "请求成功");
        ajaxResult.put("weekLogCountList", weekLogCountList);
        return ajaxResult;
    }

    @RequestMapping("/init")
    public AjaxResult homeInit(){

        AjaxResult ajaxResult = new AjaxResult(200, "请求成功");
        Integer totalUserCount = appCustomerService.countCustomerNum();
        Double totalUserPrice = appCustomerService.countCustomerPriceNum();
        Integer totalNotCheckTaskLog = appTaskOrderService.countNotCheckTaskOrder();
        ajaxResult.put("totalUserCount", totalUserCount);
        ajaxResult.put("totalUserPrice", totalUserPrice);
        ajaxResult.put("totalNotCheckTaskLog", totalNotCheckTaskLog);
        return ajaxResult;
    }
}
